#pragma once

#include <condition_variable>
#include <mutex>
#include <thread>
#include <functional>

class Request
{
public:
    uint16_t u16Sserial_;
private:
    int nOvertime_;
    int nReTry_;
private:
    std::condition_variable cv_response_;
    std::mutex mutex_cv_response_;
private:
    std::function<bool()> send_;
public:
    bool bresponse_;
public:
    Request(std::function<bool()> send, int overtime = 2, int retry = 3, int serial = 0);
    ~Request() = default;

    int GetResponse();
    int DoRequest();
private:
    int Send();
    int WaitResponse();
};